package com.huiquan.vocab.dao;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.huiquan.framework.base.EnhancedBaseDao;
import com.huiquan.vocab.domain.VocabElementRestrictSource;
import com.huiquan.vocab.domain.VocabElementSource;
import com.ibatis.sqlmap.client.SqlMapClient;

@Repository
public class VocabElementSourceDao extends EnhancedBaseDao<VocabElementSource> {

	@Resource(name = "sqlMapClient")
	private SqlMapClient sqlMapClient;

	public static final String space = "VOCAB_ELEMENT_SOURCE.";

	public VocabElementSourceDao() {
		super(space);
	}

	public void checkByIds(String ids) {
		this.update(space + "CHECK_BY_IDS", ids, sqlMapClient);
	}

	public void init() {
		this.update(space + "INIT", sqlMapClient);
	}

	public void updateRestrictSource(Long elementId, String restrictSource) {
		Map<String, Object> param = new HashMap<>();
		param.put("elementId", elementId);
		param.put("restrictSource", restrictSource);

		this.update(space + "UPDATE_RESTRICT_SOURCE", param, sqlMapClient);
	}

	public VocabElementRestrictSource retrieveRestrictSourceByElementId(Long elementId) {

		return (VocabElementRestrictSource) this.object(space + "RETRIEVE_RESTRICT_SOURCE_BY_ELEMENT_ID", elementId,
				sqlMapClient);
	}

	public void insertRestrictSource(VocabElementRestrictSource ers) {

		this.insert(space + "INSERT_RESTRICT_SOURCE", ers, sqlMapClient);
	}

}
